package com.aaa.stock.controller.examine;

import com.aaa.entity.Purchase;
import com.aaa.entity.PurchaseItem;
import com.aaa.stock.service.examine.ExamineService;
import com.aaa.stock.service.purch.PurchaseItemService;
import com.aaa.stock.service.purch.PurchaseService;
import com.aaa.stock.vo.ExamineVo;
import com.aaa.stock.vo.PurchaseVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stock/exa/examine")
public class ExamineController {
    @Autowired
    private ExamineService examineService;
    @Autowired
    private PurchaseItemService purchaseItemService;
    @Autowired
    private PurchaseService purchaseService;
    //入库审核
    @PostMapping("listPurchasePendingForPage/{currentPage}/{pageSize}")
    public Result<IPage<Purchase>> getAll(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody ExamineVo examineVo
    ){
        return examineService.getAll(currentPage,pageSize,examineVo);
    }
    //查询详情
    @PostMapping("purchaseItemAll")
    public Result<IPage<PurchaseItem>> purItemAll(@RequestBody List<PurchaseItem> purchaseItems){
        return purchaseItemService.purItemAll(purchaseItems);
    }
    //审核通过
    @GetMapping("ItemPass")
    public Result<String> ItemPass(
            @RequestParam("status")String status,
            @RequestParam String purchaseId
    ){
        return purchaseService.ItemPass(status,purchaseId);
    }
    //审核不通过
    @GetMapping("ItemNoPass")
    public Result<String> ItemNoPass(
            @RequestParam("status")String status,
            @RequestParam("purchaseId") String purchaseId,
            @RequestParam("examine") String  examine
    ){
        System.out.println("examine = " + examine);
        System.out.println("purchaseId = " + purchaseId);
        System.out.println("status = " + status);

        return purchaseService.ItemNoPass(status,purchaseId,examine);
    }
}
